'use strict';
import Vue from 'vue';
import App from './app.vue';
import Home from './components/home/home.vue';
import Member from './components/member/member.vue';
import MySwipe from './components/common/mySwipe.vue';
import NavBar from './components/common/navBar.vue';
import Shopcart from './components/shopcart/shopcart.vue';
import Search from './components/search/search.vue';
import NewsList from './components/news/newsList.vue';
import NewsDetail from './components/news/newsDetail.vue';
import PhotoShare from './components/photo/photoShare.vue';
import PhotoDeatil from './components/photo/detail.vue';
import GoodsList from './components/goods/goodsList.vue';
import GoodsDetail from './components/goods/goodsDetail.vue';
import GoodsComment from './components/goods/goodsComment.vue';

import Moment from 'moment';
import VuePreview from 'vue-preview'
// mint-ui
import Mint from 'mint-ui';
import 'mint-ui/lib/style.css';
// mui
import './static/vendor/mui/dist/css/mui.css';
// 全局样式
import './static/css/global.css'
import VueRouter from 'vue-router';
import Axios from 'axios';
Axios.defaults.baseURL = 'http://127.0.0.1:3000';

// 定义全局过滤器
Vue.filter('convertDate', function(value){
    return Moment(value).format('YYYY-MM-DD');
});
Vue.component('navBar',NavBar);
Vue.component('mySwipe',MySwipe);

Vue.use(VueRouter);
Vue.use(VuePreview);
let router = new VueRouter({
    linkActiveClass: 'mui-active',
    routes:[
        { path: '/',redirect: {name: 'home'}},
        { name: 'home',path: '/home',component: Home},
        { name: 'member',path:'/member',component: Member},
        { name: 'shopcart',path:'/shopcart',component:Shopcart},
        { name: 'search',path:'/search',component: Search},
        { name: 'news.list',path: '/news/list',component: NewsList},
        { name: 'news.detail',path: '/news/detail',component: NewsDetail},
        { name: 'photo.share',path: '/photo/share',component: PhotoShare},
        { name: 'photo.detail',path:'/photo/detail/:id',component:PhotoDeatil},
        { name: 'goods.list',path:'/goods/list',component:GoodsList},
        { name: 'goods.detail',path:'/goods/detail',component:GoodsDetail},
        { name: 'goods.comment',path:'/goods/comment',component:GoodsComment},
        
    ]
})


Vue.use(Mint)
Vue.prototype.$ajax = Axios;
// 拦截器
Axios.interceptors.request.use(function(config){
    Mint.Indicator.open({
        text: '加载中..',
        spinnerType: 'fading-circle'
    });
    return config;
})
Axios.interceptors.response.use(function(config){
    Mint.Indicator.close();
    return config;
})


new Vue({
    el: '#app',
    router,
    render: c=>c(App)
})